﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FCS.GlobalComponents
{
    /// <summary>
    /// Any number of priorities can be arbitrarily added, with highest priority first, without affecting previously written code
    /// </summary>
    /// <remarks>
    /// When adding or removing priorities, never put anything bellow patterns. In the InitRestrictedValves method in the CommandPriorityQueue, there is a loop that assumes that
    /// the patterns is the lowest priority and uses that number to create the proper number of restircted lists. If you do add anything lower than
    /// patterns, make sure you change this method or things will crash!
    /// </remarks>
    public enum CommandPriority
    {
        lmoc, music, kiosk, phone, bollards, patterns
    };

    public static class Shared
    {
        public static string GetCommandPriorityName(CommandPriority cp)
        {
            switch (cp)
            {
                case CommandPriority.lmoc: return "lmoc";
                case CommandPriority.music: return "music";
                case CommandPriority.kiosk: return "kiosk";
                case CommandPriority.phone: return "phone";
                case CommandPriority.bollards: return "bollards";
                case CommandPriority.patterns: return "patterns";
            }

            return "unknown priority level";
        }
    }

    /// <summary>
    /// These are the positions of the Horizontal valves in an array
    /// </summary>
    public enum HV
    {
        H1=0, H2, H3, H4, H5, H6, H7, H8, H9, H10, HR, HC
    }

    /// <summary>
    /// These are the positions of the Vertical valves in an array
    /// </summary>
    public enum VV
    {
        V1=0, V2, V3, V4, V5, V6, V7, V8, V9, V10, VR, VC
    }

    /// <summary>
    /// These are the positions of the North end valves in an array
    /// </summary>
    public enum NorthValves
    {
        N1 = 0, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13, N14, N15, N16, N17, N18, N19, N20, N21, N22, N23, N24
    }

    /// <summary>
    /// These are the positions of the pumps in an array
    /// </summary>
    public enum Pump
    {
        P1=0, P2, P3, P4
    }

    /// <summary>
    /// These are the positions of the Bollards in an array
    /// </summary>
    public enum Bollard
    {
        B1=0, B2, B3, B4, B5
    }

    /// <summary>
    /// These are the positions of the environmental codes in an array
    /// </summary>
    public enum Environ
    {
        NorthDisable=0, SouthDisable, SidewalkOK, ManholeClosed
    }

    /// <summary>
    /// These are the positions of the lights in an array
    /// </summary>
    public enum Lights
    {
        L1 = 0, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14
    }

    /// <summary>
    /// These are the positions of the weirs in an array
    /// </summary>
    public enum Weirs
    {
        Weir1 = 0, Weir2, Weir3
    }

    public static class FountainConstants
    {
        /// <summary>
        /// Number of valves on each of the calipers on the south end of the fountain
        /// </summary>
        public const int SouthEndValveCountPerCaliper = 12;

        /// <summary>
        /// Number of valves in the north end of the fountain
        /// </summary>
        public const int NorthEndValveCount = 24;

        /// <summary>
        /// The number of bollards on the fountain.
        /// </summary>
        public const int BollardCount = 5;

        /// <summary>
        /// The number of pumps for the fountain.
        /// Note that the state is after the bollard state in the packet from the cRIO.
        /// </summary>
        public const int PumpCount = 4;

        /// <summary>
        /// The number of weirs
        /// </summary>
        public const int WeirCount = 3;

        /// <summary>
        /// Number of lights used in winter
        /// </summary>
        public const int LightCount = 14;

        /// <summary>
        /// The number of environmental states the cRIO reports (North end HW disable, South end HW disable,
        /// Sidwalke Water level OK, Manhole cover is closed, Wind sensor (not reported))
        /// </summary>
        public const int ReportedEnvironmentalStates = 4;
    }

    /// <summary>
    /// Contains the size of packets (or partitions within a command packet) expected by the cRIO for various commands
    /// </summary>
    public static class PacketSizeConstants
    {
        /// <summary>
        /// Size of the ping packet.
        /// </summary>
        public const int Ping = 1;

        /// <summary>
        /// Size of the south end valve state packet.
        /// </summary>
        public const int SouthEndValveState = 5;

        /// <summary>
        /// Size of the north end valve state packet.
        /// </summary>
        public const int NorthEndValveState = 5;

        /// <summary>
        /// Size of the weir packet.
        /// </summary>
        public const int Weirs = 2;

        /// <summary>
        /// Size of the SetAdministrativeState command packet.
        /// </summary>
        public const int SetAdministrativeState = 1;

        /// <summary>
        /// Size of the EchoToSerialPort command packet.
        /// </summary>
        public const int EchoToSerialPort = 1;
        
        /// <summary>
        /// Size of the mister packet.
        /// </summary>
        public const int Misters = 2;

        /// <summary>
        /// Size of the light control packet.
        /// </summary>
        public const int LightControl = 15;

        /// <summary>
        /// Size of the cRIO status packet sent to the server.
        /// </summary>
        public const int CRioStatus = 3;
    }
}
    